<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fnx" uri="http://java.sun.com/jsp/jstl/functionsx" %>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="f" uri="http://www.sctv.com/tags/form" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<!DOCTYPE html>
<html>
<head>
    <jsp:include page="/WEB-INF/views/head.jsp"/>
    <style>
        .tabs {
        }

        .tabs li {
            float: left;
            background-color: #f4f4f4;
            border-left: 1px solid #e2e2e2;
            border-top: 1px solid #ddd;
            border-right: 1px solid #ddd;
            margin-right: 0px;
        }

        .tabs li a {
            color: #555555;
            float: left;
            text-decoration: none;
            padding: 5px 12px;
        }

        .tabs li a:link, .tabs li a:visited, .tabs li a:hover, .tabs li a:active {
            text-decoration: none;
        }

        .tabs li.active {
            background-color: #FFFFFF;
            border-left: 1px solid #ddd;
            border-top: 1px solid #ddd;
            border-right: 1px solid #ddd;
        }

        .tabs li.active a {
            color: #fff;
            background: #ed5565;
            border-color: #ed5565;
        }

        .tabs li.hover {
            background-color: #e7e7e7;
            border-left: 1px solid #ddd;
            border-top: 1px solid #ddd;
            border-right: 1px solid #ddd;
        }

        .tabs li.hover a {
            color: #000;
        }
    </style>
    <script>
      $(function () {
        $("#radio").buttonset();
        $("#sortHead").headSort();
        $("#tabs li").each(function () {
          $(this).hover(function () {
            if (!$(this).hasClass("active")) {
              $(this).addClass("hover");
            }
          }, function () {
            $(this).removeClass("hover");
          });
        });
        if ('${init}' == "0") {
          $("#queryBtn").click();
        }
      });

      function confirmDelete() {
        return confirm("<s:message code='confirmDelete'/>");
      }

      function optSingle(opt) {
        if (Cms.checkeds("ids") == 0) {
          alert("<s:message code='pleaseSelectRecord'/>");
          return false;
        }
        if (Cms.checkeds("ids") > 1) {
          alert("<s:message code='pleaseSelectOne'/>");
          return false;
        }
        var id = $("input[name='ids']:checkbox:checked").val();
        var url = $(opt + id).attr("href");
        if (url) {
          location.href = $(opt + id).attr("href");
        } else {
          alert("<s:message code='noPermission'/>");
        }
      }

      function optMulti(form, action, confirmMsg) {
        if (Cms.checkeds("ids") == 0) {
          alert("<s:message code='pleaseSelectRecord'/>");
          return false;
        }
        if (confirmMsg) {
          if ($.isFunction(confirmMsg)) {
            if (!confirmMsg()) {
              return false;
            }
          } else {
            if (!confirm(confirmMsg)) {
              return false;
            }
          }
        }
        form.action = action;
        form.submit();
        return true;
      }

      function optDelete(form) {
        if (Cms.checkeds("ids") == 0) {
          alert("<s:message code='pleaseSelectRecord'/>");
          return false;
        }
        if (!confirmDelete()) {
          return false;
        }
        form.action = 'nodedelete.do';
        form.submit();
        return true;
      }

      //刷新
      function optReload() {
        var form = $("#searchForm");
        form.submit();
        return true;
      }

      <c:if test="${!empty refreshLeft}">
      parent.frames["left"].location.href = "left.do";
      </c:if>
    </script>
</head>
<body class="skin-blue content-body" id="load">
<jsp:include page="/WEB-INF/views/commons/show_message.jsp"/>
<div class="content-header">
    <h1>主播栏目 - <s:message code="list"/>
        <small>(<s:message code="totalElements" arguments="${pagedList.totalElements}"/>)</small>
    </h1>
</div>
<div class="content">
    <div class="box box-primary">
        <div class="box-body table-responsive">
            <form id="searchForm" action="anchorlist.do" method="get" class="form-inline ls-search">
                <div class="form-group">
                    <label for="search_CONTAIN_name"><s:message code="node.name"/></label>
                    <input class="form-control input-sm" type="text" id="search_CONTAIN_name" name="search_CONTAIN_name"
                           value="${search_CONTAIN_name[0]}"/></label>
                </div>

                <button class="btn btn-default btn-sm" id="queryBtn" type="submit"><s:message code="search"/></button>
                <f:hidden name="queryNodeId" value="${queryNodeId}"/>
                <f:hidden name="queryNodeType" value="${queryNodeType}"/>
                <f:hidden name="queryParentId" value="${queryParentId}"/>
                <f:hidden name="returnUrl" value="anchorlist"/>
                <f:hidden id="queryStatus" name="queryStatus" value="${queryStatus}"/>
            </form>
            <form method="post">
                <tags:search_params/>
                <f:hidden name="queryNodeId" value="${queryNodeId}"/>
                <f:hidden name="queryParentId" value="${queryParentId}"/>
                <f:hidden name="returnUrl" value="anchorlist"/>
                <f:hidden name="queryNodeType" value="${queryNodeType}"/>
                <f:hidden name="queryInfoPermType" value="${queryInfoPermType}"/>
                <f:hidden name="queryStatus" value="${queryStatus}"/>
                <div class="btn-toolbar ls-btn-bar">
                    <div class="btn-group">
                        <shiro:hasPermission name="core:publish_center:create">
                            <%--<button class="btn btn-default" type="button" onclick="location.href='create.do?queryNodeId=${queryNodeId}&queryNodeType=${queryNodeType}&queryInfoPermType=${queryInfoPermType}&queryStatus=${queryStatus}&${searchstring}';"><s:message code="create"/></button>--%>
                            <button class="btn btn-default" type="button"
                                    onclick="location.href='nodecreate.do?parentId=${parent.id}&returnUrl=anchorlist&queryParentId=${queryParentId}&showDescendants=${showDescendants}&${searchstring}';">
                                <s:message code="create"/></button>
                        </shiro:hasPermission>
                    </div>
                    <div class="btn-group">
                        <shiro:hasPermission name="core:publish_center:delete">
                            <button class="btn btn-default" type="button" onclick="return optDelete(this.form);">
                                <s:message code="delete"/></button>
                        </shiro:hasPermission>
                    </div>
                    <div class="btn-group">
                        <button class="btn btn-default" type="button" onclick="return optReload(this.form);">刷新</button>
                    </div>
                    <div class="btn-group">
                        <shiro:hasPermission name="core:sinatv:generationTv01">
                            <button class="btn btn-default" type="button"
                                    onclick="$('#load').showLoading();location.href='/cmscp/core/generation/generationDataByNode.do?returnUrl=/cmscp/core/pub_center/forward&queryNodeId=${parent.id}';">
                                生成
                            </button>
                        </shiro:hasPermission>
                    </div>
                </div>

                <table id="pagedTable" class="table table-condensed table-bordered table-hover ls-tb">
                    <thead id="sortHead" pagesort="<c:out value='${page_sort[0]}' />" pagedir="${page_sort_dir[0]}"
                           pageurl="list.do?page_sort={0}&page_sort_dir={1}&queryNodeId=${queryNodeId}&queryNodeType=${queryNodeType}&queryInfoPermType=${queryInfoPermType}&queryStatus=${queryStatus}&${searchstringnosort}">
                    <tr class="ls_table_th">
                        <th width="25"><input type="checkbox" onclick="Cms.check('ids',this.checked);"/></th>
                        <th width="30"><span>ID</span></th>
                        <th><span>栏目名称</span></th>
                        <th><span>节目标签</span></th>
                        <th><span>关联主播</span></th>
                        <th><span>总期数</span></th>
                        <th><span>播放次数</span></th>
                        <th><span>最近更新</span></th>
                        <th width="180">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach var="bean" varStatus="status" items="${pagedList.content}">
                        <tr<shiro:hasPermission
                                name="core:info:edit"> ondblclick="location.href=$('#edit_opt_${bean.id}').attr('href');"</shiro:hasPermission>>
                            <td><input type="checkbox" name="ids" value="${bean.id}"/></td>
                            <td align="center"><c:out value="${bean.id}"/></td>
                            <td align="center">
                                <div>
                                    <a href="infolist.do?id=${bean.id}&queryNodeId=${bean.id}&queryNodeType=${queryNodeType}&queryInfoPermType=${queryInfoPermType}&queryStatus=${queryStatus}&position=${pagedList.number*pagedList.size+status.index}"
                                       title="<c:out value='${bean.title}'/>"><c:out
                                            value="${fnx:substringx_sis(bean.title,30,'...')}"/></a></div>
                            </td>
                            <td align="center">
                                <div>
                                    <span style="color:blue;"><c:out value="${bean.customs.nodeTag}"/></span>
                                </div>
                            </td>
                            <td align="center">
                                <div>
                                    <c:forEach var="nodeAnchor" varStatus="status" items="${bean.nodeAnchors}">
                                        <span style="color:blue;"><c:out value="${nodeAnchor.anchor.name}"/></span>
                                    </c:forEach>
                                </div>
                            </td>
                            <td align="center"><c:out value="${bean.customs.totalPeriods}"/></td>
                            <td align="center"><c:out value=""/></td>
                            <td align="center">
                                <div><fmt:formatDate value="${bean.creationDate}" pattern="yyyy-MM-dd HH:mm:ss"/></div>
                            </td>
                            <td align="center">
                                <shiro:hasPermission name="core:publish_center:edit">
                                    <a id="edit_opt_${bean.id}"
                                       href="nodeedit.do?id=${bean.id}&position=${pagedList.number*pagedList.size+status.index}&returnUrl=anchorlist&queryParentId=${queryParentId}&showDescendants=${showDescendants}&${searchstring}"
                                       class="ls-opt">编辑</a>
                                </shiro:hasPermission>
                                <shiro:hasPermission name="core:publish_center:delete">
                                    <a href="nodedelete.do?ids=${bean.id}&queryParentId=${queryParentId}&returnUrl=anchorlist&showDescendants=${showDescendants}&${searchstring}"
                                       onclick="return confirmDelete();" class="ls-opt"><s:message code="delete"/></a>
                                </shiro:hasPermission>
                            </td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
                <c:if test="${fn:length(pagedList.content) le 0}">
                    <div class="ls-norecord"><s:message code="recordNotFound"/></div>
                </c:if>
            </form>
            <form action="anchorlist.do" method="get" class="ls-page">
                <tags:search_params excludePage="true"/>
                <f:hidden name="queryParentId" value="${queryParentId}"/>
                <%--<f:hidden name="queryNodeType" value="${queryNodeType}"/>--%>
                <%--<f:hidden name="queryInfoPermType" value="${queryInfoPermType}"/>--%>
                <%--<f:hidden id="queryStatus" name="queryStatus" value="${queryStatus}"/>--%>
                <tags:pagination pagedList="${pagedList}"/>
            </form>
        </div>
    </div>
</div>
</body>
</html>